import React, { Component } from 'react';
import {HashRouter as Router,Route,Switch} from "react-router-dom"

import Layout from "./component/layout/layout"
import Main from "./component/main/main"
import Login from "./page/login/login"
import ErrorPage from "./page/errorPage/errorPage"
import UserList from "./page/userList/userList"
import Product from "./page/product/product"
import AddProduct from "./page/product/addProduct/addProduct"
import Save from "./page/product/save/save"
import ProductDetail from "./page/product/product_detail/productDetail"


import "./App.css"
class App extends Component {
  render() {
    return (
     <Router>
     <Switch>
      <Route path="/login" component={Login}></Route>
      
      <Route  path="/" render={(props)=>{
        return (
          <Layout>
            <Switch>
            <Route exact path="/" render={(props)=>{
              return <Main />
            }}>
            </Route>
            <Route path="/user" render={(props)=>{
              return <UserList />
            }}></Route>
            <Route  path="/product" exact render={(props)=>{
              return (
              <Product>
              </Product>)
            }}>
            </Route>
            <Route path="/product/add" component={AddProduct}>
            </Route>
            <Route path="/product/save" component={Save}>
            </Route>
            <Route path="/product/save:productId" component={Save}>
            </Route>
            
            <Route  render={(props)=>{
              return <ErrorPage />
            }
            }></Route>
              
              
            </Switch>
          </Layout>
        )
      }}></Route>
     </Switch>  
     </Router>
    );
  }
}

export default App;
